package com.longnuoqi.mydoctor.adapter;

import android.content.Context;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.longnuoqi.mydoctor.entity.Ask;
import com.yunhe.mydoctor.R;

import java.util.List;


/**
 * Created by Lenovo on 2015/12/26.
 */
public class DoctorListViewAdapter extends BaseAdapter {
    private List<Ask> list;
    private Context context;
    private LayoutInflater inflater;
    public DoctorListViewAdapter(Context context,List<Ask> list){
        this.context = context;
        this.list = list;
        inflater = LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(convertView==null){
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.doctor_listview_item,null);
            holder.img = (ImageView) convertView.findViewById(R.id.doctor_item_img);
            holder.time = (TextView) convertView.findViewById(R.id.doctor_item_time_txt);
            holder.content = (TextView) convertView.findViewById(R.id.doctor_item_content_txt);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        holder.img.setImageResource(R.mipmap.yijinejue);
        holder.time.setText(list.get(position).getTime());
        holder.content.setText(list.get(position).getTitle());
        holder.content.setTag(list.get(position).getId());
        return convertView;
    }
    private class ViewHolder{
        public ImageView img;
        public TextView content;
        public TextView time;
    }
}
